//package com.winner.mybatisplus.config;
//
//import java.util.Arrays;
//import java.util.List;
//import java.util.Optional;
//import java.util.stream.Collectors;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.core.annotation.Order;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import org.springframework.web.multipart.MultipartFile;
//
//import com.alibaba.fastjson2.JSON;
//import com.winner.mybatisplus.util.IpUtil;
//
//import lombok.extern.slf4j.Slf4j;
//
///**
// * 使用AOP打印请求参数及返回参数
// *
// * @author : wangxinle5
// * @Date: 2022/04/25
// */
//@Aspect
//@Component
//@Order(1)
//@Slf4j
//public class AspectConfig {
//
//    // @Pointcut("execution(* com.winner.mybatisplus.controller..*.*(..))")
//    @Pointcut("@within(org.springframework.web.bind.annotation.RestController)  || @within(org.springframework.stereotype.Controller)")
//    private void webLog() {}
//
//    @Before(value = "webLog()")
//    public boolean before(JoinPoint joinPoint) {
//        ServletRequestAttributes requestAttributes =
//            (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
//        HttpServletRequest request = requestAttributes.getRequest();
//        log.info("请求日志的打印");
//        log.info("请求用户的真实IP地址: {}", IpUtil.getIpAddress(request));
//        log.info("请求地址:{}", Optional.ofNullable(request.getRequestURI()).orElse(null));
//        log.info("请求方式:{}", request.getMethod());
//        log.info("请求类方法:{}", joinPoint.getSignature());
//        if (!request.getRequestURI().contains("upload")) {
//            log.info("请求类方法参数:{}", JSON.toJSONString(filterArgs(joinPoint.getArgs())));
//        }
//        return true;
//    }
//
//
//    private List<Object> filterArgs(Object[] objects) {
//        return Arrays.stream(objects).filter(obj -> !(obj instanceof MultipartFile)
//            && !(obj instanceof HttpServletResponse) && !(obj instanceof HttpServletRequest))
//            .collect(Collectors.toList());
//    }
//}
